package patrol.mobile.com.mobilepatrol.activity.road_block;

import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

import butterknife.BindView;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.api.Urls;
import patrol.mobile.com.mobilepatrol.fragment.BaseFragment;
import patrol.mobile.com.mobilepatrol.utils.Constants;
import patrol.mobile.com.mobilepatrol.utils.SPUtils;

/**
 * Created by apple on 18/1/24.
 */

public class BlockMesFragment extends BaseFragment {
    @BindView(R.id.wv)
    WebView wv;

    @BindView(R.id.pb_progress)
    ProgressBar pb;


    @Override
    protected int getLayoutId() {
        return R.layout.block_mes;
    }


    @Override
    protected void initListener() {

    }

    @Override
    protected void initView() {
        super.initView();
        String url = SPUtils.get(Constants.current_ser,"")+ Urls.blockInfoList;
        wv.setWebChromeClient(new WebChromeClient());
        wv.setWebViewClient(new WebViewClient());
        wv.getSettings().setJavaScriptEnabled(true);
        wv.loadUrl("http://222.82.247.6:9092/a/map/mapquery/querypage?mapType=blockInfoList");
        wv.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onReceivedTitle(WebView view, String title) {
                super.onReceivedTitle(view, title);
            }

            @Override
            public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) {
                super.onReceivedTouchIconUrl(view, url, precomposed);
            }
        });
        wv.setWebChromeClient(new WebChromeClient(){
            public void onProgressChanged(WebView view, int newProgress) {
                pb.setProgress(newProgress);
                if (newProgress == 100) {
                    pb.setVisibility(View.GONE);
                }
                else {
                    if (pb.getVisibility()==View.GONE)
                        pb.setVisibility(View.VISIBLE);
                    pb.setProgress(newProgress);
                }
                super.onProgressChanged(view, newProgress);
            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
